package com.guli.thirdpart.thirdpart;

import com.aliyun.oss.OSS;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.FileInputStream;

@SpringBootTest
@RunWith(SpringRunner.class)
public class OssDemo {

    @SuppressWarnings("all")
    @Autowired
    private OSS ossclient;

    @Value("${alibaba.cloud.oss.bucketName}")
    private String bucketName;

    @Test
    public void test01(){
        System.out.println(ossclient);
        try {
            ossclient.putObject(bucketName,"ll.jpg",new FileInputStream("C:\\Users\\86131\\Pictures\\Screenshots\\小新.jpg"));
            System.out.println("图片上传成功");
        }catch (Exception e){
            e.printStackTrace();
        }


    }

}
